﻿using order_project;

class Program
{
    static void Main(string[] args)
    {
        OrderService service = new OrderService();

        // 示例添加订单
        try
        {
            Order order1 = new Order { OrderId = 1, Customer = "Alice", OrderDetails = new List<OrderDetail> { new OrderDetail { ProductName = "Apple", UnitPrice = 10, Quantity = 3 } } };
            service.AddOrder(order1);

            Order order2 = new Order { OrderId = 2, Customer = "Bob", OrderDetails = new List<OrderDetail> { new OrderDetail { ProductName = "Banana", UnitPrice = 5, Quantity = 5 } } };
            service.AddOrder(order2);

            // 示例查询
            var ordersByCustomer = service.QueryOrdersByCustomer("Alice");
            foreach (var order in ordersByCustomer)
            {
                Console.WriteLine(order);
            }

            // 示例删除
            service.RemoveOrder(1);
            // 示例修改
            Order newOrder = new Order { OrderId = 2, Customer = "Bob", OrderDetails = new List<OrderDetail> { new OrderDetail { ProductName = "Orange", UnitPrice = 7, Quantity = 10 } } };
            service.ModifyOrder(2, newOrder);

            // 再次查询
            var updatedOrdersByCustomer = service.QueryOrdersByCustomer("Bob");
            foreach (var order in updatedOrdersByCustomer)
            {
                Console.WriteLine(order);
            }

            // 查询特定产品的订单
            var ordersByProduct = service.QueryOrdersByProduct("Orange");
            foreach (var order in ordersByProduct)
            {
                Console.WriteLine(order);
            }

            // 查询订单金额大于等于特定值的订单
            var ordersByAmount = service.QueryOrdersByAmount(50);
            foreach (var order in ordersByAmount)
            {
                Console.WriteLine(order);
            }

            // 排序示例
            Console.WriteLine("Sorted by Custom Sort (Total Amount):");
            service.CustomSort(o => o.TotalAmount());
            foreach (var order in service.QueryOrdersByAmount(0))
            {
                Console.WriteLine(order);
            }

        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }

        Console.WriteLine("Press any key to exit.");
        Console.ReadKey();
    }
}




